﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    EnableEventValidation="false" CodeFile="Items.aspx.cs" Inherits="Items" Trace="false" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
    <style type="text/css">
        div.items ul.productList li
        {
            float: left;
            list-style: none outside none;
        }
    </style>
    <script type="text/javascript">
        function BlockUI(elementID) {
            var prm = Sys.WebForms.PageRequestManager.getInstance();
            prm.add_beginRequest(function () {
                $("#" + elementID).block({ message: '<table align = "center" class="StatusBar"><tr><td>' +
     '<img src="loadingAnim.gif"/></td></tr></table>',
                    css: {},
                    overlayCSS: { backgroundColor: '#000000', opacity: 0.6, border: '3px solid #63B2EB'
                    }
                });
            });

            prm.add_endRequest(function () {
                $("#" + elementID).unblock();
            });
        }

        $(document).ready(function () {
            BlockUI("dvGrid");
            $.blockUI.defaults.css = {};
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <h1 id="itemListTitle" runat="server" style="text-align: center; text-decoration: underline;
        text-transform: capitalize; font-size: xx-large; font-weight: bolder; margin-bottom: 25px;">
        Products in this department</h1>
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <div id="dvGrid" style="padding-top: 10px; padding-bottom: 10px; width: 100%">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Label ID="lblFilterBy" Text="Filter by:" runat="server" />
                <asp:Label ID="lblFilterCategory" Text="category:" runat="server" />
                <asp:DropDownList ID="CategoryFilterDropDownList" runat="server" ViewStateMode="Enabled"
                    DataTextField="name" DataValueField="categoryCode">
                </asp:DropDownList>
                <asp:Label ID="lblFilterType" Text="type:" runat="server" />
                <asp:DropDownList ID="ddlTypesFilter" runat="server" ViewStateMode="Enabled" DataTextField="name"
                    DataValueField="typeCode">
                </asp:DropDownList>
                <asp:Button ID="btnApplyFilter" Text="Apply filters" runat="server" OnClick="btnApplyFilter_Click" />
                <asp:Button ID="btnClearFilters" Text="Clear filters" runat="server" OnClick="btnClearFilters_Click" />
                <div class="items" style="">
                    <asp:ListView ID="itemsList" runat="server" GroupItemCount="2">
                        <LayoutTemplate>
                            <table style="width: 100%">
                                <tr>
                                    <td>
                                        <table style="width: 100%; text-align: center; vertical-align: middle; border: 1px solid red;"
                                            cellpadding="5">
                                            <asp:PlaceHolder runat="server" ID="groupPlaceHolder"></asp:PlaceHolder>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </LayoutTemplate>
                        <GroupTemplate>
                            <tr>
                                <asp:PlaceHolder runat="server" ID="itemPlaceHolder"></asp:PlaceHolder>
                            </tr>
                        </GroupTemplate>
                        <ItemTemplate>
                            <td style="border: 1px solid red;">
                                <h3>
                                    <asp:HyperLink NavigateUrl='<%# "~/Product.aspx?code=" +  Eval("productCode") %>'
                                        runat="server" Text='<%# Eval("name") %>' />
                                </h3>
                                <br />
                                <img alt="<%# Eval("name") %>" src="Images/Image_not_found.jpg" />
                                <h3>
                                    <asp:Label ID="lblPrice" Text='<%# "Price: " +  Eval("price") + " EUR"%>' runat="server"></asp:Label><br />
                                </h3>
                            </td>
                        </ItemTemplate>
                        <EmptyDataTemplate>
                            <div>
                                We are sorry - products with chosen properties could not be found.
                            </div>
                        </EmptyDataTemplate>
                    </asp:ListView>
                    <asp:DataPager ID="dpListView" runat="server" PagedControlID="itemsList" PageSize="4">
                        <Fields>
                            <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True" />
                        </Fields>
                    </asp:DataPager>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
</asp:Content>
